//
//  ScanIdStore.m
//  NewPro
//
//  Created by RYX on 2018/10/29.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "ScanIdStore.h"
#import "RealNameParametersModel.h"

@implementation ScanIdStore

#pragma mark - 实名认证
- (void)postRealNameWithParameters:(RealNameParametersModel *)parametersModel Success:(void(^)(void))success Failure:(void(^)(NSError *error))failure{
    
    /*
     分别是：customId用户ID，idCardNumber身份证号，name姓名，idCardFrontImgData身份证前照，idCardBackImgData身份证后照，bankno银行卡号，khzh开户支行，bank银行名，bankFrontImgData银行正面照，bankBackImgData照片
     */
    
    
    NSString *url = [NSString stringWithFormat:@"%@/api/submitIdCardInfo",IP];
    
//    NSArray *regionArr = [parametersModel.region componentsSeparatedByString:@" "];
//    NSArray *bankaddArr = [parametersModel.bankadd componentsSeparatedByString:@" "];
    
    NSDictionary *dic = @{
                          @"customId":[UserDefaultsManager sharedInstance].user_id,
                          @"idCardNumber":parametersModel.idCardNumber,
                          @"name":parametersModel.name,
                          @"bankno":parametersModel.bankno,
                          @"khzh":parametersModel.khzh,
                          @"bank":parametersModel.bank,
                          @"region":parametersModel.region,
                          @"bankadd":parametersModel.bankadd,
                          @"idCardFrontImgData":parametersModel.idCardFrontImgData,
                          @"idCardBackImgData":parametersModel.idCardBackImgData,
                          @"bankFrontImgData":parametersModel.bankFrontImgData,
                          @"bankBackImgData":parametersModel.bankBackImgData
                          };
    
    [HttpTool postUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        
        if (error == nil) {
            
            success();
        }else{
            
            failure(error);
        }
        
    } failure:^(NSError *error) {
       
        failure(error);
    }];
}

@end
